
<?php
require 'Controller.php ';
require 'Admin/Model/TypeModel.php';
class TypeController extends Controller{
	function __Construct(){
		parent::__Construct();
	
	}
	function listtypes(){
		
		$model = new TypeModel();
		$data = $model->getTypeList();
		$this->assign('cartoontype',$data);
		$this->display(); 
		//return $data;

	}
function deltype(){
			$tid=$_GET['tid'];//根据cid查找要删除的动漫
			$model=new TypeModel();
			$result=$model->delType($tid);
			if($result){
				echo "删除成功!3秒后跳转回动漫列表页";
				header("refresh:3;url='admin.php?c=type&m=listtypes'");//隔3秒跳回

			}
			else{
				echo "删除失败!";
				echo "<a href='admin.php?c=type&m=listtypes'>返回动漫列表</a>";
				
			}
		}
function regtype(){
	       $this->display();
}
function addtype(){
	$data=$_POST;
    $model=new TypeModel();
    $result=$model->addtype($data);
    if ($result) {
    	echo "注册成功，3秒后返回动漫列表页。";
    	header("refresh:3;url='admin.php?c=type&m=listtypes'");
    }else{
    	echo "注册失败，3秒后返回动漫添加页重新添加。";
    	header("refresh:3;url='admin.php?c=type&m=regtype'");
    }

}
function edittype(){
	$tid=$_GET['tid'];
	$model=new TypeModel();
	$data=$model->edittype($tid);
    $this->assign('type',$data);
    $this->display();

}
function updatetype(){
	$data=$_POST;
	$model=new TypeModel();
	$result=$model->updatetype($data);
	if($result){
		echo "修改成功，3秒后返回动漫列表页。";
    	header("refresh:3;url='admin.php?c=type&m=listtypes'");
    }else{
    	echo "修改失败!";
    	echo "<a href='admin.php?c=type&m=listtypes'>";
    }
}

function searchtype(){
	    $typename=$_POST;;
	    $model = new TypeModel();
		$data = $model->searchtype($typename);
		$this->assign('type',$data);
		$this->display(); 


}







}
?>

